//import produce from "immer";
import { actionType } from "./action.js";


const initialState = {
  name:'张三',
  age:18,
};
export default function counter(state = initialState, action) {
  console.log("Reducer called with action:", state,action);

  //从 action 中解构出 type 和 data
  const { type, data } = action;

  // 根据 action 的 type 执行不同的操作
  let name = state.name;
  switch (type) {
    case actionType.UPDATE:
      name = data;
      break;
    default:
      //return state.count;
  }
  console.log("Reducer state:", state);
  return {
    ...state,
    name,
  } ;
}
